
var page;
var NewSetPage = function (recordCount, id) {
	var pageCount = 0;
	var pageSize = 2;
	if (parseInt(recordCount % pageSize) == 0) {//计算总页数 
		pageCount = parseInt(recordCount / pageSize);
	} else {
		pageCount = parseInt(recordCount / pageSize) + 1;
	}
	page = new SetPage(pageCount, id);
	return page;
};
var SetPage = function (pageCount, id) {
	this.currentpage = 1;
	this.pageSize = 2;
	this.pageCount = pageCount;
	this.id = id;
	this.loadPage(this.currentpage);
	this.toPage(1);
};
SetPage.prototype.toPage = function (page) {
	var html="";
	if (this.pageCount >= 1) {
		//html = "<span id=\"info\">\u5171" + this.pageCount + "\u9875|\u7b2c" + page + "\u9875</span>";
		if (page > 10) {
			html += "<a style=\"width:30px;\" href=\"javascript:page.gototab(0)\"><<</a>";
		}
		for (i = parseInt((page - 1) / 10) * 10 + 1; i <= this.pageCount; i++) {
			if (i == page) {
				html += "<span class=\"current\">" + i + "</span>";
			} else {
				html += "<a href=\"javascript:page.gotopage(" + i + ")\">" + i + "</a>";
			}
			if (i == (parseInt((page - 1) / 10) + 1) * 10) {
				break;
			}
		}
		if (parseInt((page - 1) / 10) < parseInt(this.pageCount / 10)) {
			html += "<a style=\"width:30px;\" href=\"javascript:page.gototab(1)\">>></a>";
		}
		document.getElementById(this.id).innerHTML = html;
		document.getElementById(this.id).className = this.id;
		document.getElementById(this.id).style.display = "block";
	}else{
		document.getElementById(this.id).innerHTML="";
		document.getElementById(this.id).style.display = "none";
	}
};
SetPage.prototype.gotopage = function (page) {
	this.currentpage = page;
	this.loadPage(this.currentpage);
	this.toPage(page);
};
SetPage.prototype.gototab = function (tab) {
	if (tab == 1) {
		this.currentpage = (parseInt((this.currentpage - 1) / 10) + 1) * 10 + 1;
	} else {
		if (tab == 0) {
			this.currentpage = (parseInt((this.currentpage - 1) / 10) - 1) * 10 + 1;
		}
	}
	//this.loadPage(this.currentpage);
	this.toPage(this.currentpage);
};
SetPage.prototype.loadPage = function (page) {
	//TODO:it is use load the current page data.
	loadPageMember(this.currentpage,this.pageSize);
};

